/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * viewDosen.java
 *
 * Created on Mar 21, 2014, 3:09:14 PM
 */
package view;

import java.awt.Color;
import java.awt.Image;
import java.io.File;
import kelas.Dosen;
import java.sql.SQLException;
import java.text.Normalizer.Form;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import jxl.Sheet;
import jxl.Workbook;
import kontrol.DosenKontrol;
import tabelModel.Dosen_TM;
import tabelModel.renderWarnaWarni;

/**
 *
 * @author Adhi
 */
public class viewDosen extends javax.swing.JFrame {

    /**
     * Creates new form viewDosen
     */
    public viewDosen() {
        try {
            initComponents();
            setLocationRelativeTo(null);
            updateTabelDosen();

            uploadData.setFileSelectionMode(JFileChooser.FILES_ONLY);
            uploadData.setMultiSelectionEnabled(false);
            FileNameExtensionFilter JExcelFilter = new FileNameExtensionFilter("Excel File 2003 .xls", "xls");
            uploadData.setFileFilter(JExcelFilter);
            uploadData.setAcceptAllFileFilterUsed(false);
        } catch (SQLException ex) {
            Logger.getLogger(viewDosen.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        uploadData = new javax.swing.JFileChooser();
        jPanel1 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        homeButton = new javax.swing.JButton();
        matkulButton = new javax.swing.JButton();
        dosenButton = new javax.swing.JButton();
        ruangButton = new javax.swing.JButton();
        kelasButton = new javax.swing.JButton();
        penjadwalanButton = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        idDosenText = new javax.swing.JTextField();
        namaDosenText = new javax.swing.JTextField();
        Status_ComboBox = new javax.swing.JComboBox();
        simpanButton = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        batalButton = new javax.swing.JButton();
        editButton = new javax.swing.JButton();
        hapusButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabelDosen = new javax.swing.JTable();
        jLabel5 = new javax.swing.JLabel();
        button_upload = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();

        uploadData.setApproveButtonToolTipText("");
        uploadData.setDialogTitle("PILIH FILE DOSEN");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("SISTEM PENJADWALAN MATAKULIAH PGSD USD - INFORMASI DOSEN");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(204, 204, 204));
        jPanel1.setForeground(new java.awt.Color(204, 204, 204));
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel3.setBackground(new java.awt.Color(102, 102, 102));
        jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        homeButton.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        homeButton.setText("HOME");
        homeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                homeButtonActionPerformed(evt);
            }
        });
        jPanel3.add(homeButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 10, 80, 40));

        matkulButton.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        matkulButton.setText("MATAKULIAH");
        matkulButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                matkulButtonActionPerformed(evt);
            }
        });
        jPanel3.add(matkulButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 10, 140, 40));

        dosenButton.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        dosenButton.setText("DOSEN");
        dosenButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dosenButtonActionPerformed(evt);
            }
        });
        jPanel3.add(dosenButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 10, 100, 40));

        ruangButton.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        ruangButton.setText("RUANG");
        ruangButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ruangButtonActionPerformed(evt);
            }
        });
        jPanel3.add(ruangButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 10, 100, 40));

        kelasButton.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        kelasButton.setText("BUAT KELAS KULIAH");
        kelasButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                kelasButtonActionPerformed(evt);
            }
        });
        jPanel3.add(kelasButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 10, -1, 40));

        penjadwalanButton.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        penjadwalanButton.setText("PENJADWALAN");
        penjadwalanButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                penjadwalanButtonActionPerformed(evt);
            }
        });
        jPanel3.add(penjadwalanButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(720, 10, 150, 40));

        jPanel1.add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 150, 940, 60));

        jPanel4.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel1.setText("ID Dosen");
        jPanel4.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 80, -1, -1));

        jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel2.setText("Nama Dosen");
        jPanel4.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 120, -1, -1));

        jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jLabel3.setText("Status");
        jPanel4.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 160, -1, -1));

        idDosenText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                idDosenTextActionPerformed(evt);
            }
        });
        jPanel4.add(idDosenText, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 80, 206, -1));
        jPanel4.add(namaDosenText, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 120, 206, -1));

        Status_ComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tetap", "Tidak Tetap" }));
        jPanel4.add(Status_ComboBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 160, 98, -1));

        simpanButton.setText("SIMPAN");
        simpanButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                simpanButtonActionPerformed(evt);
            }
        });
        jPanel4.add(simpanButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 230, -1, 50));

        jLabel4.setFont(new java.awt.Font("NSimSun", 1, 18)); // NOI18N
        jLabel4.setText("TABEL DOSEN");
        jPanel4.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(630, 40, -1, -1));

        batalButton.setText("BATAL");
        batalButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                batalButtonActionPerformed(evt);
            }
        });
        jPanel4.add(batalButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 230, 70, 50));

        editButton.setText("UBAH");
        editButton.setEnabled(false);
        editButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editButtonActionPerformed(evt);
            }
        });
        jPanel4.add(editButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 230, -1, 50));

        hapusButton.setText("HAPUS");
        hapusButton.setEnabled(false);
        hapusButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hapusButtonActionPerformed(evt);
            }
        });
        jPanel4.add(hapusButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 230, -1, 50));

        tabelDosen.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tabelDosen.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tabelDosenMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tabelDosen);

        jPanel4.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 80, 380, 190));

        jLabel5.setFont(new java.awt.Font("NSimSun", 1, 18)); // NOI18N
        jLabel5.setText("DATA DOSEN");
        jPanel4.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 40, -1, -1));

        button_upload.setText("UPLOAD");
        button_upload.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_uploadActionPerformed(evt);
            }
        });
        jPanel4.add(button_upload, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 230, 90, 50));

        jPanel1.add(jPanel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 210, 940, 320));

        jPanel5.setBackground(new java.awt.Color(255, 102, 0));
        jPanel5.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel6.setFont(new java.awt.Font("Wide Latin", 1, 19)); // NOI18N
        jLabel6.setText("Pendidikan Guru Sekolah Dasar");
        jPanel5.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 30, -1, -1));

        jLabel7.setFont(new java.awt.Font("Bodoni MT", 0, 18)); // NOI18N
        jLabel7.setText("Fakultas Keguruan dan Ilmu Pendidikan - Universitas Sanata Dharma");
        jPanel5.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 50, -1, -1));

        jLabel8.setFont(new java.awt.Font("Microsoft Himalaya", 0, 24)); // NOI18N
        jLabel8.setText("Telp (0274) 513301, 515352, Fax. (0274) 562383 ");
        jPanel5.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 110, -1, -1));

        jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gambar/logo.gif"))); // NOI18N
        jPanel5.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 0, -1, 150));

        jLabel10.setFont(new java.awt.Font("Microsoft Himalaya", 0, 24)); // NOI18N
        jLabel10.setText("Mrican, Tromol Pos 29, Yogyakarta 55002.");
        jPanel5.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 80, -1, -1));

        jPanel1.add(jPanel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 940, 150));

        jPanel2.setBackground(new java.awt.Color(255, 102, 0));
        jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
        jPanel1.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 530, 940, 80));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 940, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 610, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void homeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_homeButtonActionPerformed
        Home asd = new Home();
        asd.setVisible(true);
        this.setVisible(false);
}//GEN-LAST:event_homeButtonActionPerformed

    private void matkulButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_matkulButtonActionPerformed
        viewMataKuliah asd = new viewMataKuliah();
        asd.setVisible(true);
        this.setVisible(false);
}//GEN-LAST:event_matkulButtonActionPerformed

    private void dosenButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dosenButtonActionPerformed
        viewDosen asd = new viewDosen();
        asd.setVisible(true);
        this.setVisible(false);
}//GEN-LAST:event_dosenButtonActionPerformed

    private void ruangButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ruangButtonActionPerformed
        viewRuang asd = new viewRuang();
        asd.setVisible(true);
        this.setVisible(false);
}//GEN-LAST:event_ruangButtonActionPerformed

    private void kelasButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kelasButtonActionPerformed
        viewKelas asd = new viewKelas();
        asd.setVisible(true);
        this.setVisible(false);
}//GEN-LAST:event_kelasButtonActionPerformed

    private void penjadwalanButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_penjadwalanButtonActionPerformed
        viewPenjadwalan asd = new viewPenjadwalan();
        asd.setVisible(true);
        this.setVisible(false);
}//GEN-LAST:event_penjadwalanButtonActionPerformed

    private void idDosenTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idDosenTextActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_idDosenTextActionPerformed

    private void simpanButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_simpanButtonActionPerformed
        String id = idDosenText.getText();
        String nama = namaDosenText.getText();
        String Combo = (String) Status_ComboBox.getSelectedItem();
        Dosen temp = new Dosen(id, nama, Combo);
        try {
            DosenKontrol dosenk = DosenKontrol.getKoneksi();
            dosenk.insertDosen(temp);
            JOptionPane.showMessageDialog(null, "Data Dosen " + nama + " Berhasil di Simpan");
            updateTabelDosen();
            bersihkan();
            idDosenText.requestFocus();

        } catch (SQLException e) {
            JOptionPane.showMessageDialog(null, "Gagal di simpan");
            bersihkan();
        }
    }//GEN-LAST:event_simpanButtonActionPerformed

    private void batalButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_batalButtonActionPerformed
        bersihkan();
    }//GEN-LAST:event_batalButtonActionPerformed

    private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed
        String id = idDosenText.getText();
        String nama = namaDosenText.getText();
        String Combo = (String) Status_ComboBox.getSelectedItem();
        Dosen temp = new Dosen(id, nama, Combo);

        try {
            DosenKontrol dosenk = DosenKontrol.getKoneksi();
            dosenk.updateDosen(temp);
            JOptionPane.showMessageDialog(null, "Data Dosen " + nama + " Berhasil di Ubah");
            bersihkan();
            updateTabelDosen();
            idDosenText.requestFocus();

        } catch (SQLException e) {
            JOptionPane.showMessageDialog(null, "Gagal di rubah");
            bersihkan();
        }
    }//GEN-LAST:event_editButtonActionPerformed

    private void hapusButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hapusButtonActionPerformed
        String id = idDosenText.getText();
        String nama = namaDosenText.getText();
        String Combo = (String) Status_ComboBox.getSelectedItem();
        Dosen temp = new Dosen(id, nama, Combo);

        int data = JOptionPane.showConfirmDialog(null, "Apakah Mau menghapus " + temp.getIdDosen() + " - " + temp.getNamaDosen() + "?", "MENGHAPUS DATA", 1);
        if (data == 0) {
            try {
                DosenKontrol dosenk = DosenKontrol.getKoneksi();
                dosenk.deleteDosen(temp);
                JOptionPane.showMessageDialog(null, "Data Dosen " + nama + " Berhasil di hapus");
                updateTabelDosen();
                bersihkan();
                idDosenText.requestFocus();

            } catch (SQLException e) {
                JOptionPane.showMessageDialog(null, "Gagal di hapus");
                bersihkan();
            }
        } else {
        }
    }//GEN-LAST:event_hapusButtonActionPerformed

    private void tabelDosenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelDosenMouseClicked
        int row1 = tabelDosen.getSelectedRow();
        String idDosen = tabelDosen.getValueAt(row1, 0).toString();
        String namaDosen = tabelDosen.getValueAt(row1, 1).toString();
        String status = tabelDosen.getValueAt(row1, 2).toString();
        idDosenText.setText(idDosen);
        namaDosenText.setText(namaDosen);
        Status_ComboBox.setSelectedItem(status);

        idDosenText.setEditable(false);
        simpanButton.setEnabled(false);
        editButton.setEnabled(true);
        hapusButton.setEnabled(true);
    }//GEN-LAST:event_tabelDosenMouseClicked

    private void button_uploadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_uploadActionPerformed
        int jes = uploadData.showOpenDialog(this);

        if (jes == uploadData.APPROVE_OPTION) {
//            File f = uploadData.getSelectedFile();
//           jLabel1.setText(f.getPath());
//           JOptionPane.showMessageDialog(null, f.getPath());

            File excelFile = uploadData.getSelectedFile();

            // buat model untuk file excel
            if (excelFile.exists()) {
                try {
                    Workbook workbook = Workbook.getWorkbook(excelFile);
                    Sheet sheet = workbook.getSheets()[0];

                    TableModel model = new DefaultTableModel(sheet.getRows(), sheet.getColumns());
                    for (int row = 1; row < sheet.getRows(); row++) {
                        String content = "";
                        for (int column = 0; column < sheet.getColumns(); column++) {
                            content = content + sheet.getCell(column, row).getContents() + "-";
                        }
                        boolean result = DosenKontrol.getKoneksi().cekDosen(content.split("-")[0]);
                        Dosen dos = new Dosen(content.split("-")[0], content.split("-")[1], content.split("-")[2]);
                        if (result == true) {
                            DosenKontrol.getKoneksi().updateDosen(dos);
                        } else {
                            DosenKontrol.getKoneksi().insertDosen(dos);
                        }
                    }
                    JOptionPane.showMessageDialog(null, "Data Berhasil Dimasukkan Ke dalam Database");
                    updateTabelDosen();
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Error: Format Dokumen tidak sesuai dengan database Dosen");
                }

            } else {
                JOptionPane.showMessageDialog(null, "File does not exist");
            }
        }
    }//GEN-LAST:event_button_uploadActionPerformed

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
        Image oldIcon = getIconImage();
        ImageIcon newIcon = createImageIcon("/gambar/dosen.png");
        setIconImage(newIcon.getImage());
    }//GEN-LAST:event_formWindowActivated

    private void bersihkan() {
        idDosenText.setText("");
        namaDosenText.setText("");
        idDosenText.setEditable(true);
        Status_ComboBox.setSelectedIndex(0);
        simpanButton.setEnabled(true);
        editButton.setEnabled(false);
        hapusButton.setEnabled(false);
    }

    private void updateTabelDosen() throws SQLException {
        List<Dosen> dtm = DosenKontrol.getKoneksi().tampilDosen();
        Dosen_TM model = new Dosen_TM(dtm);
        tabelDosen.setModel(model);

        tabelDosen.getColumnModel().getColumn(0).setMinWidth(70);
        tabelDosen.getColumnModel().getColumn(0).setMaxWidth(70);
        tabelDosen.getColumnModel().getColumn(1).setMinWidth(220);
        tabelDosen.getColumnModel().getColumn(1).setMaxWidth(220);

        tabelDosen.setDefaultRenderer(Object.class, new renderWarnaWarni(Color.lightGray, Color.white));
    }

    public static void main(String args[]) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            java.awt.EventQueue.invokeLater(new Runnable() {

                @Override
                public void run() {
                    new viewDosen().setVisible(true);
                }
            });
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(viewDosen.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(viewDosen.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(viewDosen.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(viewDosen.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox Status_ComboBox;
    private javax.swing.JButton batalButton;
    private javax.swing.JButton button_upload;
    private javax.swing.JButton dosenButton;
    private javax.swing.JButton editButton;
    private javax.swing.JButton hapusButton;
    private javax.swing.JButton homeButton;
    private javax.swing.JTextField idDosenText;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton kelasButton;
    private javax.swing.JButton matkulButton;
    private javax.swing.JTextField namaDosenText;
    private javax.swing.JButton penjadwalanButton;
    private javax.swing.JButton ruangButton;
    private javax.swing.JButton simpanButton;
    private javax.swing.JTable tabelDosen;
    private javax.swing.JFileChooser uploadData;
    // End of variables declaration//GEN-END:variables

    protected static ImageIcon createImageIcon(String path) {
        // Ganti IconFrame dengan nama kelas jFrame Anda
        java.net.URL imgURL = Form.class.getResource(path);
        if (imgURL != null) {
            return new ImageIcon(imgURL);
        } else {
            System.err.println("Couldn'’t find file: " + path);
            return null;
        }
    }
}
